﻿using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using RouterControl.IO;
using System.Diagnostics;
using System.Windows.Forms;

namespace RouterControl.WhsAddIn.Wizards.SelectRouter.FeatureTests
{
    internal abstract class Diagnosis
    {
        public enum DiagResult
        {
            Success,
            Failure,
            Abort       // skips all following tests
        }

        protected readonly ILog _log;

        public ListViewItem ListItem
        {
            get;
            private set;
        }

        public virtual int ProgressWeight
        {
            get { return 100; }
        }

        public abstract DiagResult Run();

        protected Diagnosis(string title)
        {
            _log = LogManager.GetLogger(GetType());

            this.ListItem = new ListViewItem()
            {
                Text = title,
                ImageIndex = 0
            };

        }

        protected void LogProperties(object o)
        {
            if (o == null)
                throw new ArgumentNullException("o");

            foreach (var p in o.GetType().GetProperties())
                _log.DebugFormat("... {0} = \"{1}\"", p.Name, p.GetValue(o, null));
        }

    }
}